<extend name="Console:index"/>
<block name="main">

    <!--路径导航-->
        <div>
            <ol class="breadcrumb">
                <li>商品管理</li>
            </ol>
        </div>
    <div >
        <div style="float:left">
            <form class="form-search form-inline" method="get" action="{:U('Goods/index')}">
                <input class="form-control" type="text" name="name"  placeholder="名字" value="{$search['name']}"/>
                <input class="form-control" type="text" name="title"  placeholder="标题" value="{$search['title']}"/>
                <input class="form-control" type="text" name="number"  placeholder="库存" value="{$search['number']}"/>

               <span class="btn btn-default btn-sm">
                     <input type="radio" name="st" value="1"   <eq name="search['st']" value="1">checked</eq> /> <span class="h5">启用</span>
                     <input type="radio" name="st" value="2"   <eq name="search['st']" value="2">checked</eq> /><span class="h5">下架</span>
                </span>

                <button class="form-control btn btn-warning" >搜索</button>

            </form>
        </div>


        <div style="float:right">

            <a href="{:U('Goods/add')}" class="btn btn-info">新增商品</a>
            <a href="{:U('Goods/index')}" class="btn btn-primary">全部数据</a>
            <a href="{:U('Goods/delList')}" class="btn btn-default" >回收站</a>
        </div>
        <div style="clear: both"></div>

        <div style="height: 10px"></div>
            <div>

                <table class="table table-bordered ">
                    <tr>
                        <th>序号</th>
                        <th>id</th>
                        <th>名称(N)/标题(T)</th>
                        <th>尺寸</th>
                        <th>颜色</th>
                        <th>库存</th>
                        <th>价格</th>
                        <th>商品基础参数</th>
                        <th>商品图片</th>
                        <th>商品详情</th>
                        <th>商品其他图片</th>
                        <th>时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    <volist name="list" id="l" key="k">
                        <tr>
                            <td style="width: 80px" ><input type="checkbox" name="check"  value="{$l.id}"/> {$k}</td>
                            <td style="width: 80px" >
                                {$l.id}<br>
                                <b>品牌:{$l.brand}</b>
                            </td>
                            <td style="width: 200px">N:{$l.name}<br>
                                T:{$l.title}<br>
                                	店铺:<b>{$l.movie_name}</b><br>
                              		  二级目录:<b>{$l.movie_level2_name}</b><br>

                            </td>
                            <td style="width: 100px">
                                <volist name="l.size" id="size">
                                    {$size}<br>
                                </volist>
                            </td>

                            <td style="width: 100px">
                                {$l.color}
                            </td>
                            <td style="width: 100px">
                                {$l.number}
                            </td>
                            <td style="width: 100px">
                                	销售价格:<br>{$l.sale_price}<br>
                                	原价格:<br>{$l.price}
                            </td>

                            <td>
                                <volist name="l.base_info" id="base">
                                    <span class="glyphicon glyphicon-chevron-left" style="color: red"></span>
                                    {$base.name} :{$base.val}
                                    <span class="glyphicon glyphicon-chevron-right" style="color: red"></span>

                                </volist>
                                <br>
                                <b>关联商品ID:{$l.relevance_goods_id}</b>
                            </td>

                            <td>
                                <volist name="l.picture" id="picture">
                                    <a href="{$picture}" target="_blank"><img style='width:50px;' src="{$picture}" alt="图片无法上传"></a>
                                </volist>
                            </td>
                            <td>
                                <volist name="l.details_picture" id="d_picture">
                                    <a href="{$d_picture}" target="_blank"><img style='width:50px;' src="{$d_picture}" alt="图片无法上传"></a>
                                </volist>

                            </td>

                            <td>
                               剧照商品: <a href="{$l.stage_photo}">  <img src="{$l.stage_photo}" alt="图片没有上传" style='width:50px;'> </a><br>
                               正方形商品: <a href="{$l.square_photo}">  <img src="{$l.square_photo}" alt="图片没有上传" style='width:50px;'> </a><br>
                               圆形商品: <a href="{$l.roundness_photo}">  <img src="{$l.roundness_photo}" alt="图片没有上传" style='width:50px;'> </a><br>
                            </td>

                            <td style="width: 200px">
                                创建:{$l.create_time|date='Y-m-d H:i:s',###}<br>
                                更新:{$l.last_update_time|date='Y-m-d H:i:s',###}
                            </td>

                            <td style="width: 100px">
                                <eq name="l.status" value="1">
                                    <a href="###" class="btn btn-success btn-sm" data-id="{$l.id}" data-type="off" >已启用</a>
                                </eq>

                                <eq name="l.status" value="2">
                                    <a href="###" class="btn btn-danger btn-sm" data-id="{$l.id}" data-type="on" >已下架</a>
                                </eq>

                                <eq name="l.status" value="3">
                                    已删除
                                </eq>

                            </td>

                            <td style="width: 100px">
                                <a href="{:U('Goods/edit',array('id'=>$l['id']))}" class="btn btn-warning">编辑</a>

                            </td>
                        </tr>
                    </volist>

                    <tr>
                        <td><input type="checkbox" name="" id="allChecked"/>ALL</td>
                        <td colspan="13" >
                            <div >
                                <a href="#" class="btn btn-warning btn-sm" id="btn_on">启用</a>
                                <a href="#" class="btn btn-danger btn-sm" id="btn_off">下架</a>
                                <a href="#" class="btn btn-danger btn-default" id="btn_del">删除</a>
                                <a href="{:U('Goods/add')}" class="btn btn-info">新增明星</a>
                            </div>

                        </td>
                    </tr>

                 </table>
            </div>
            <div class="text-center">
               {$page}
            </div>
        </div>

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script>
        $(function(){
            //选择了的数据集合
            function allchecked()
            {
                var checked = '';
                $("input[name='check']:checked").each(function () {
                    checked += $(this).prop('value') + ',';
                });
                return checked;
            }

            //全选/全不选
            $('#allChecked').click(function(){
                if ($("#allChecked").prop("checked")) {
                    $(":checkbox").prop("checked", true);
                } else {
                    $(":checkbox").prop("checked", false);
                }
            });

            //更改状态的函

            function alter(type,ids)
            {
                var t = type;
                var idlsit ;
                if(ids){
                    idlist = ids;
                }else{
                    idlist = allchecked();
                }

                $.post('{:U("Goods/alter")}',{'idlist':idlist,'type':t},function(data){
                    alert(data.mes);
                    window.location.reload();
                });
            }

            $('#btn_on').click(function(){if(confirm('你确定要对进行  "启用"  操作吗?')) alter('on');});
            $('#btn_off').click(function(){if(confirm('你确定要对进行  "下架"  操作吗?')) alter('off');});
            $('#btn_del').click(function(){if(confirm('你确定要对进行  "删除"  操作吗?')) alter('del');});

            $("[href='###']").click(function(){
                var id = $(this).attr('data-id');
                var type = $(this).attr('data-type');
                var strType;
                if( type =='on' ){
                    strType = '启用';
                }
                if( type == 'off'){
                    strType = '下架';
                }
                if( type == 'del'){
                    strType = '删除';
                }

                if(confirm('你确定要对进行  '+strType+'  操作吗?')){
                    alter(type,id);
                }

            })

        });


    </script>

</block>
